<style>
.jy2-headertop {position: absolute;padding-top:0.3rem;padding-bottom:0.3rem;margin-top:-2rem;height:auto;border-top-right-radius:1rem;border-top-left-radius:1rem;}
.fui-header a.back:before {border-color: #fff}
.fui-header:after {border-bottom: 0 solid #D9D9D9;}
.fui-tab {background: none;}
</style>
<div ng-if="pagedata.op=='get'" class='fui-page  fui-page-current coupon-my-page'>
    <div class="topbg" style="position: relative;text-align:center;width:100%;height:4.5rem;background: {{main.syscolor || '#7c1cc9'}};">
            <div class="fui-header" style="background:none">
                <div class="fui-header-left">
                    <a class="back" style="color:#fff" href="javascript:" ng-click="goback()"></a>
                </div>
                <div class="title bold" style="font-size:1rem;color:#fff">购物卡中心</div>
            </div>
    </div>
    <div class='fui-content jy2-headertop' style="padding-top:0.8rem;background:#f7f7f7">
        <div class='fui-tab fui-tab-danger' id='cateTab'>
            <a href="javascript:;" ng-click="pagedata.gettypelist=pagedata.list;pagedata.type=1" ng-class="{'active':pagedata.type==1}">充值兑换</a>
            <a href="javascript:;" ng-click="pagedata.gettypelist=pagedata.listgame;pagedata.type=2" ng-class="{'active':pagedata.type==2}">活动赠送</a>
			<a href="javascript:;" ng-click="pagedata.gettypelist=pagedata.listsong;pagedata.type=3" ng-class="{'active':pagedata.type==3}">朋友赠送</a>
        </div>
        <div ng-if="pagedata.gettypelist.length<1" class="fui-message fui-message-popup in content-empty" style=" margin-top: 0; padding-top: 0; position: relative; height: auto; background: none;">
            <div class="icon ">
                <i class="icon icon-information"></i>
            </div>
            <div class="content">暂时没有合适您的购物卡~</div>
        </div>
        <div id="container" class="coupon-container coupon-list" ng-repeat="item in pagedata.gettypelist">
            <a href="javascript:;" class="coupon-item  {{item.card.color}}">
            <div class="coupon-dots">
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
                <i>
                </i>
            </div>
            <div class="coupon-left">
                <div class="bold" style="font-size:1.3em">{{item.money}}</div>
                <div class="subtitle">购物卡</div>
            </div>
            <div class="coupon-right">
                <div class="title">{{item.title}}</div>
                <div>售价<span class="red bold"> ￥{{item.price}}</span></div>
                <div class="subtitle">{{item.desc}}</div>
                <div class="usetime">
                    <div class="text">
                      <div ng-if="item.timelimittype==0">有效期: 永久有效</div>
                      <div ng-if="item.timelimittype==1">获得后{{item.timedays}}天内有效</div>
                      <div ng-if="item.timelimittype==2">指定时间段内有效</div>
                    </div>
                    <div class="usebtn">
                        <div ng-if="pagedata.type==1" ng-click="pagedata.buy(item.id)">立即购买</div>
                        <div ng-if="pagedata.type==2" ng-click="post({id:item.id},'jy_weishop/member.getcard/getcard/')">立即领取</div>
						<div ng-if="pagedata.type==3" ng-click="access_json('jy_weishop/member.getcard/detail/id='+item.id);">去分享</div>
                    </div>
                </div>
            </div>
            </a>
        </div>
    </div>
</div>
<div ng-if="pagedata.op=='detail'" class="fui-page">
	<div class="fui-header">
		<div class="fui-header-left">
			<a class="back" href="javascript:;" ng-click="access_json('jy_weishop/member.getcard/')"></a>
		</div>
		<div class="title">详情</div>
		<div class="fui-header-left"></div>
	</div>
	<div class="fui-content navbar coupon-page">
		<div class="coupon-detail {{pagedata.item.card.color}}">
			<div class="detail-dots"></div>
			<div class="detail-head">
				<div class="inner">
					<div class="title">
						<div class="text">{{pagedata.item.card.title}}</div>
					</div>
					<div class="bigtitle">面值 {{pagedata.item.card.money}}</div>				
					<div class="usetime">
						<div class="text">有效期:
							{{pagedata.item.card.time}}
						</div>
					</div>
				</div>
			</div>
			<div class="detail-body">
				<div class="block">
				
					<div ng-if="pagedata.item.card.merchid!=0" class="title">使用商铺</div>
					
					<div class="text dot" ng-if="pagedata.item.card.merchid!=0" >
						限购[{{pagedata.item.card.merchname}}]店铺商品
					</div>	
					
					<div class="title">使用说明</div>
					<div class="text">
						<div ng-if="pagedata.item.card.isdescsys==1">
								{{pagedata.setting.desc}}
						</div>
						<div ng-if="pagedata.item.card.isdescsys==0">
							{{pagedata.item.card.desc}}
						</div>
					</div>
				</div>
				<div class="block">
					<div class="title">有效期限</div>
					<div class="text">
						有效期:{{pagedata.item.card.time}}
					</div>
				</div>
				<div class="block">
					<div class="title">使用限制</div>
						<div ng-if="pagedata.item.card.limitusetype==1" class="text">不允许与促销优惠同时使用</div>
						<div ng-if="pagedata.item.card.limitusetype==2" class="text">不允许与会员折扣同时使用</div>
						<div ng-if="pagedata.item.card.limitusetype==3" class="text">不允许与促销优惠和会员折扣同时使用</div>
						<div ng-if="pagedata.item.card.limitgoodtype==1" class="text">允许以下商品使用:</div>
						<div ng-if="pagedata.item.card.limitgoodtype==1">
							<span ng-repeat="item in pagedata.item.goods" class="jylabel jylabel-red" style="margin:0.1rem;line-height:2">{{item.title}}</span>
						</div>
						<div  ng-if="pagedata.item.card.limitgoodcatetype==1"  class="text">允许以下商品分类使用:</div>
						<div>
							<span ng-repeat="item in pagedata.item.group" class="jylabel jylabel-red" style="margin:0.1rem;line-height:2">{{item.title}}</span>
						  </div>
						<div ng-if="pagedata.item.card.limitgoodtype==0 && pagedata.item.card.limitgoodcatetype==0 &&  pagedata.item.card.limitusetype==0 &&  pagedata.item.card.coupontype!=2" class="text">无</div>
				</div>
			</div>
		</div>
	</div>
	<div class="fui-navbar">				
		<div class="nav-item btn btn-gray"  ng-if="pagedata.item.card.past==1" >
			已过期
		</div>
		<div class="nav-item btn btn-{{pagedata.item.card.color}}" ng-if="pagedata.item.card.past!=1" >
				<a ng-if="pagedata.item.card.gettype==1" ng-click="pagedata.buy(pagedata.item.cardid)">立即购买</a>
                <a ng-if="pagedata.item.card.gettype==2" ng-click="post({id:pagedata.item.cardid},'jy_weishop/member.getcard/getcard/')">立即领取</a>
				<a ng-if="pagedata.item.card.gettype==3 && !pagedata.tofromuser" onclick="$('#showsharecover').modal();">去分享</a>
				<a ng-if="pagedata.item.card.gettype==3 && pagedata.tofromuser" ng-click="post({id:pagedata.item.cardid},'jy_weishop/member.getcard/getcard/')">立即领取</a>
		</div>
	</div>
</div>
<!--分享弹层-->
<div id="showsharecover" class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
<div class="modal-dialog" style="width:100%;left:0;top:0">
	<div id="cover">
		<div class='fui-mask-m visible'></div>
		<div class='arrow'></div>
		<div class='content'>请点击右上角<br/>通过【发送给朋友】<br/>送购物卡给朋友</div>
	</div>
</div>
</div>
<script>
scope.pagedata.buy=function(id){
    scope.post_json('jy_weishop/member.getcard/buy/',{'id':id},function(pay_id){
        console.log('pay_id');console.log(pay_id);
        require(['tool'],function(tool){
            tool.pay(pay_id,function(res){
                console.log('收到支付结果！');
                if(res.type=='success'){
                    scope.message('兑换成功！','','jy_weishop/member.mycard/');
                }else{
                    scope.message('兑换失败！'+res.message,'','goback');
                }
            });
        });
    });
}
</script>